package com.study.www.demo2filter.web;

import com.alibaba.fastjson.JSONObject;
import com.study.www.demo.Application;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import javax.servlet.AsyncContext;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

/**
 * @author : Administrator.zhuyanpeng
 * @date : 2019/11/15 - 16:52
 */
@Slf4j
@RequestMapping("/demo2")
@RestController
public class Demo2Controller {

    public static Map<String,String> map;

    @PostConstruct
    public void init(){
        map = new HashMap<>(2);
        map.put("1","AAA");
        map.put("2","bbb");
    }

    @GetMapping("/getTest2/{id}")
    public JSONObject getTest(@PathVariable String id){
        log.warn("DemoController 的 getTest ;启动时间=>"+new DateTime().toString(Application.DATEFORMAT));
        JSONObject jsonObject = new JSONObject();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        jsonObject.put("id", Demo2Controller.map.get(id));
        return jsonObject;
    }

}
